#!/usr/bin/python
#encoding=UTF-8
'''
in pyQT
   re = getList.getValue()
        for i in range(10):
            for j in range(4):
                item = QtGui.QTableWidgetItem(QtGui.QApplication.translate("Dialog", re[i][j], None, QtGui.QApplication.UnicodeUTF8))
                self.tableWidget.setItem(i, j, item)
        
'''

import urllib,re,time

def getValue():
	date = time.strftime('%Y-%m-%d')
	url = 'http://news.cngold.org/index.html'
	wp = urllib.urlopen(url)
	result = wp.read()

	start = result.find('热点排行')
	end = result.find('民生经济')
	
	result =result[start:end]

	myUrl = re.findall('http.*html',result)
	
	myKeyword = re.findall('title=".*\">',result)
	
	res=[[0 for col in range(4)] for row in range(10)]
	for i in range(10):
		myKeyword[i] = myKeyword[i].replace(r'title="','').replace(r'">','')
		sWp = urllib.urlopen(myUrl[i])
		sResult = sWp.read()
		AttentionRate = re.search('\d{4}</a',sResult)
		att =AttentionRate.group(0).replace('</a','')
		res[i][0]=att
		res[i][1]=myKeyword[i]
		res[i][2]=date
		res[i][3]=myUrl[i]
	return res

if __name__ == "__main__":
	re = getValue()
	print re[9][0]